import time

from selenium.webdriver.support.wait import WebDriverWait
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://www.jianshu.com/p/7e2b63ed0292")

WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//section[position()=2]/div/div")))

while True:
    try:
        next_btn = driver.find_element_by_xpath("//section[position()=2]/div/div")
        driver.execute_script('arguments[0].click();',next_btn)
    except:
        break

subjects = driver.find_elements_by_xpath("//section[position()=2]/div/a/span")
for subject in subjects:
    print(subject.text)

time.sleep(3)
driver.close()
driver.quit()
        











